Skip to content

fix: fix polygonize dropping body area for polygons with touching holes#2

Merged
bvacherot-sofar merged 1 commit intomainfrom
bvacherot/polygonize_drops_area_repro
Apr 24, 2026
Merged

fix: fix polygonize dropping body area for polygons with touching holes#2
bvacherot-sofar merged 1 commit intomainfrom
bvacherot/polygonize_drops_area_repro

Conversation

@bvacherot-sofar
Copy link
Copy Markdown
Contributor

@bvacherot-sofar bvacherot-sofar commented Apr 24, 2026

Relevant test:

  • polygonize_preserves_enclosed_taiwan_polygon_minimal_matches_fixture a small repro case. The initial polygons cover Taiwan, and the output polygons do not.
  • src/graph/topology_cleanup.rs the proposed fix

Root cause in split_touching_boundary_polygon: the split_faces.len() >= 2 branch assumes the extracted minimal edge rings fully tile the original polygon body. That assumption only holds when the body is simply connected (one connected component). For a polygon with holes whose body is multiply-connected (exterior — holes forms one piece), the body cannot be represented as a single minimal edge ring and the extracted sub-faces only cover "pockets" between touching holes; the bulk of the body is silently discarded.

Fix (src/graph/topology_cleanup.rs): gate the >= 2 split branch on the original polygon's interior_point() being covered by at least one split face. When the coverage check fails on a holed polygon, fall back to select_non_touching_holes, which preserves the exterior.

@bvacherot-sofar bvacherot-sofar force-pushed the bvacherot/polygonize_drops_area_repro branch from a1241f8 to 8ebd9f0 Compare April 24, 2026 23:02
Copy link
Copy Markdown
Collaborator

@apendleton apendleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bvacherot-sofar bvacherot-sofar changed the title fix: fix polygonize edge case where bulk of body is discarded fix: fix polygonize dropping body area for polygons with touching holes Apr 24, 2026
@bvacherot-sofar bvacherot-sofar merged commit 8a62c02 into main Apr 24, 2026
4 checks passed
@bvacherot-sofar bvacherot-sofar deleted the bvacherot/polygonize_drops_area_repro branch April 24, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants